#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
class Node {
public:
    int val;
    vector<Node*> children;

    Node() {}

    Node(int _val) {
        val = _val;
    }

    Node(int _val, vector<Node*> _children) {
        val = _val;
        children = _children;
    }
};


class Solution {
public:
    vector<vector<int>> levelOrder(Node* root) {
        vector<vector<int>> ret;
        queue<Node*> as;
        if (root == nullptr)
            return ret;
        as.push(root);
        while (as.size())
        {
            int s = as.size();
            vector<int> tmp;
            for (int i = 0; i < s; i++)
            {
                Node* qw = as.front();
                as.pop();
                tmp.push_back(qw->val);
                for (Node* child : qw->children)
                {
                    as.push(child);
                }
            }
            ret.push_back(tmp);
        }
        return ret;
    }
};